package com.liziing.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;



@Configuration
public class WebInfoConfigurer implements WebMvcConfigurer {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    //让拦截器生效
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new WebInfoHandlerInterceptor(stringRedisTemplate))
                .addPathPatterns("/**")  //拦截所有路径
                .excludePathPatterns("/user/login", "/user/register", "/user/resetPwd");  //排除登录， 注册
    }
}
